import router from '@/router';
import store from '@/store';

const initUserRoutes = (newRoutesData: any) => {
  newRoutesData.forEach((item: any) => {
    const formatedRoute = {
      path: item.path,
      name: item.name,
      component: () => {
        return import('../components/' + item.component + '.vue');
        // return import('../components/MyComponent.vue');
      }
    };
    router.addRoute(formatedRoute);
  });
  store.commit('LOGIN_USER_DATA', newRoutesData);
  console.log('增加route之后，routes = ', router.getRoutes());
};
export default initUserRoutes;
